#include "common.hpp"
#include "serve.hpp"
#include "Dict.hpp"
void Usage(char *argv)
{
    std::cerr << argv[0] << " " << "port";
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
    }

    // 取端口号
    uint16_t port = std::stoi(argv[1]);
    // 翻译模块
    Dict dict;
    dict.LoadDict();

    std::unique_ptr<Serve> tsvr = std::make_unique<Serve>(port, [&dict](std::string word, InetAddr peer)
                                                          { return dict.Translate(word, peer); }); // 转到上层 执行()重载 调用Dict中方法
    tsvr->Init();
    tsvr->Run();
    return 0;
}